// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'
import Client from '@api/visitor/api/VisitorRecordApi'

import TempClass from '@api/visitor/model/QueryVisitorRecordBodyTempTotalReq'
import OrganClass from '@api/visitor/model/QueryVisitorRecordOrgTotalReq'
import ReserveClass from '@api/visitor/model/CountVisitorRecordTotalByTimeReq'

const ArriveClass = ReserveClass

const CLIENT = CORE.grpcCLIENT(Client)

// ============================== 导出远程接口 ============================== //

export default {
  // —————————————————————————————— 体温 —————————————————————————————— //

  async getTemp(param, TIP = '查询体温统计') {
    const DTO = CORE.grpcDTO(TempClass, param)
    const resp = await CORE.grpc(TIP, CLIENT, 'countRecordTotalByBodyTemp', DTO)
    return resp.content || []
  },

  // —————————————————————————————— 部门 —————————————————————————————— //

  async getOrgan(param, TIP = '查询部门统计') {
    const DTO = CORE.grpcDTO(OrganClass, param)
    const resp = await CORE.grpc(TIP, CLIENT, 'countRecordTotalByOrg', DTO)
    return resp.content || []
  },

  // —————————————————————————————— 预约 —————————————————————————————— //

  async getReserve(param, TIP = '查询预约统计') {
    const DTO = CORE.grpcDTO(ReserveClass, { ...param, visitorType: 3 })
    const resp = await CORE.grpc(TIP, CLIENT, 'countVisitorRecordTotalByTime', DTO)
    return resp.visitorRecordTotalDto || []
  },

  // —————————————————————————————— 到访 —————————————————————————————— //

  async getArrive(param, TIP = '查询到访统计') {
    const DTO = CORE.grpcDTO(ArriveClass, { ...param, visitorType: 1 })
    const resp = await CORE.grpc(TIP, CLIENT, 'countVisitorRecordTotalByTime', DTO)
    return resp.visitorRecordTotalDto || []
  },
}
